<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <button >开始倒计时</button>
    <p></p>
    <script>
        var btn=document.querySelector('button');
        var text=document.querySelector('p');
        var time=5;
        btn.onclick=function(){
            setInterval(() => {
                if(time==0){
                location.href='http://www.baidu.com'
            }
                text.innerHTML=''+time+'秒后将进入百度！'
                time--;
            }, 1000);
        }
    </script>
</body>
</html>